<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Delay Slots (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="Delay Slots (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="Delay Slots (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html" rel="start" title="Top">
<link href="Option-Index.html" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Insn-Attributes.html" rel="up" title="Insn Attributes">
<link href="Processor-pipeline-description.html" rel="next" title="Processor pipeline description">
<link href="Mnemonic-Attribute.html" rel="prev" title="Mnemonic Attribute">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en">
<span id="Delay-Slots"></span><div class="header">
<p>
Next: <a href="Processor-pipeline-description.html" accesskey="n" rel="next">Processor pipeline description</a>, Previous: <a href="Mnemonic-Attribute.html" accesskey="p" rel="prev">Mnemonic Attribute</a>, Up: <a href="Insn-Attributes.html" accesskey="u" rel="up">Insn Attributes</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<span id="Delay-Slot-Scheduling"></span><h4 class="subsection">17.19.8 Delay Slot Scheduling</h4>
<span id="index-delay-slots_002c-defining"></span>

<p>The insn attribute mechanism can be used to specify the requirements for
delay slots, if any, on a target machine.  An instruction is said to
require a <em>delay slot</em> if some instructions that are physically
after the instruction are executed as if they were located before it.
Classic examples are branch and call instructions, which often execute
the following instruction before the branch or call is performed.
</p>
<p>On some machines, conditional branch instructions can optionally
<em>annul</em> instructions in the delay slot.  This means that the
instruction will not be executed for certain branch outcomes.  Both
instructions that annul if the branch is true and instructions that
annul if the branch is false are supported.
</p>
<p>Delay slot scheduling differs from instruction scheduling in that
determining whether an instruction needs a delay slot is dependent only
on the type of instruction being generated, not on data flow between the
instructions.  See the next section for a discussion of data-dependent
instruction scheduling.
</p>
<span id="index-define_005fdelay"></span>
<p>The requirement of an insn needing one or more delay slots is indicated
via the <code>define_delay</code> expression.  It has the following form:
</p>
<div class="example">
<pre class="example">(define_delay <var>test</var>
              [<var>delay-1</var> <var>annul-true-1</var> <var>annul-false-1</var>
               <var>delay-2</var> <var>annul-true-2</var> <var>annul-false-2</var>
               &hellip;])
</pre></div>

<p><var>test</var> is an attribute test that indicates whether this
<code>define_delay</code> applies to a particular insn.  If so, the number of
required delay slots is determined by the length of the vector specified
as the second argument.  An insn placed in delay slot <var>n</var> must
satisfy attribute test <var>delay-n</var>.  <var>annul-true-n</var> is an
attribute test that specifies which insns may be annulled if the branch
is true.  Similarly, <var>annul-false-n</var> specifies which insns in the
delay slot may be annulled if the branch is false.  If annulling is not
supported for that delay slot, <code>(nil)</code> should be coded.
</p>
<p>For example, in the common case where branch and call insns require
a single delay slot, which may contain any insn other than a branch or
call, the following would be placed in the <samp>md</samp> file:
</p>
<div class="example">
<pre class="example">(define_delay (eq_attr &quot;type&quot; &quot;branch,call&quot;)
              [(eq_attr &quot;type&quot; &quot;!branch,call&quot;) (nil) (nil)])
</pre></div>

<p>Multiple <code>define_delay</code> expressions may be specified.  In this
case, each such expression specifies different delay slot requirements
and there must be no insn for which tests in two <code>define_delay</code>
expressions are both true.
</p>
<p>For example, if we have a machine that requires one delay slot for branches
but two for calls,  no delay slot can contain a branch or call insn,
and any valid insn in the delay slot for the branch can be annulled if the
branch is true, we might represent this as follows:
</p>
<div class="example">
<pre class="example">(define_delay (eq_attr &quot;type&quot; &quot;branch&quot;)
   [(eq_attr &quot;type&quot; &quot;!branch,call&quot;)
    (eq_attr &quot;type&quot; &quot;!branch,call&quot;)
    (nil)])

(define_delay (eq_attr &quot;type&quot; &quot;call&quot;)
              [(eq_attr &quot;type&quot; &quot;!branch,call&quot;) (nil) (nil)
               (eq_attr &quot;type&quot; &quot;!branch,call&quot;) (nil) (nil)])
</pre></div>

<hr>
<div class="header">
<p>
Next: <a href="Processor-pipeline-description.html" accesskey="n" rel="next">Processor pipeline description</a>, Previous: <a href="Mnemonic-Attribute.html" accesskey="p" rel="prev">Mnemonic Attribute</a>, Up: <a href="Insn-Attributes.html" accesskey="u" rel="up">Insn Attributes</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
